<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // const let var
        let str = 'abc', str1 = 'bbb'
        const abc = 'abc', test = 'nnn'
        var a = 'abc', b = 'abc'
        let bbb
        console.log(bbb, 'bbb')
        if (true) {
            var test1 = '123'
        }
        console.log(test1, 'test1')

        for (var i = 0; i < 4; i++) {

        }
        console.log(i, 'i')
        let j = 0
        while (j < 2) {
            var test1 = '456'
            j++
        }
        console.log(test1, 'test1')

        {
            var str2 = 'string'
        }
        console.log(str2, 'str2')

        switch (1) {
            case 1:
                var str3 = 'str3'
                break
        }
        console.log(str3, 'str3')
        try {
            var str4 = 'str4'
        } catch {

        }
        console.log(str4, 'str4')
    </script>
    <script>
        //Map,weakMap
        const map = new Map()
        map.set(+0, '1')
        map.set(-0, '2')
        console.log(map.get(+0))
        console.log([...map.keys()])
        console.log(map.has(+0))

        console.log(map.delete(+0))
        console.log([...map.values()])


        const wp = new WeakMap()
        let key = {}
        wp.set(key, 'abc')
        console.log(wp.get(key))
        console.log(wp.has(key))
        console.log(wp.delete(key))
    </script>
    <script>
        //Set,WeakSet
        const set = new Set()
        set.add('abc')
        set.add({ a: 1 })
        set.add({ a: 1 })
        set.add({})
        console.log(set.has('abc'), 'set')
        console.log([...set.keys()])
        console.log([...set.values()])
        console.log(set.delete({}))
        console.log(set.clear())
        console.log([...set.values()])
    </script>
    <script>
        //解构赋值
        const obj = {
            a1: 1, b1: 2, c1: {
                d1: 3,
                e1: {
                    f1: 4
                }
            }
        }

        let { a1, b1, c1 } = obj
        a1 = 11;
        b1 = 22
        c1.d1 = 33

        console.log(obj, 'obj')
    </script>
    <script>
        //Symbol
        const key1 = Symbol('id')
        const key2 = Symbol.for('id')
        const key3 = Symbol.for('id')
        console.log(key2, 'key2')
        console.log(key3, 'key3')
        console.log(key3 === key3)
        console.log(Symbol.keyFor(key2))
    </script>
    <script>
        //BigInt
        const aa = BigInt('88888888888888888888888888888888')
        const bb = BigInt('11111111111111111111111111111111')
        const aa1 = BigInt(88888888888888888888888888888888)
        const bb1 = BigInt(11111111111111111111111111111111)
        console.log((aa + bb).toString(), 'bigInt')
        console.log((aa1 + bb1), 'bigInt')  //失真，BigInt参数最好是字符串
    </script>
    <script>
        //对象
        const objs = {
            a: 1, b: 2, c: 3, d: {
                e: {
                    f: 2
                }
            }
        }
        console.log([...Object.keys(objs)], 'object')
        console.log([...Object.values(objs)])
        console.log(Object.assign(objs, { a: 2 }))
        console.log(Object.assign([12, 2, 3], [5, 6]))  //[5,6,3] {0:12,1:2,2:3}  {0:5,1:6}

        console.log(Object.assign(1, { a: 1 }))
        console.log(Object.assign('', {}))

        console.log(Object.is(+0, -0))  //false
        console.log(Object.is(NaN, NaN))  //TRUE
        console.log()
    </script>
    <script>
        //数组
        const arr1 = new Array(10).fill('a')
        console.log(arr1, 'arr1')
        console.log(Array.of(1, 2, 3, 4))
        function fn() {
            console.log([...arguments])
            console.log(Array.from(arguments))
        }
        fn(1, 2, 3, 4)

    </script>
    <script>
        //箭头函数
        const add = (...argus) => {
            console.log(this, 'this')
            console.log([...argus])
        }
        add(1, 2, 3)
    </script>
    <script>
        setTimeout(() => console.log(1), 0)  //2 abc data 3 4 1
        async function main() {
            console.log('2')
            const res = await new Promise(resolve => {
                console.log('abc')
                resolve('data')
            })
            console.log(res,'res')
            console.log('3')
        }
        main()
        Promise.resolve().then(() => console.log('4'))
    </script>
    <script>
        const s1 = Symbol('id')
        console.log(!!s1,'s1')
        console.log(Boolean(s1),'s1')
        console.log(s1.toString())
        console.log(String(s1))
    </script>
</body>

</html>